﻿using GalaSoft.MvvmLight;
using MuddyBoots.GreenlightQC.Mobile.UI.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace MuddyBoots.GreenlightQC.Mobile.UI.ViewModel
{
    public abstract class ViewModel : ViewModelBase
    {
        protected override void RaisePropertyChanged<T>(Expression<Func<T>> expression)
        {
            this.RaisePropertyChanged(ExpressionHelper.Name(expression));
        }

        protected virtual void SetPropertyAndNotify<T>(ref T currentValue, T newValue, Expression<Func<T>> propertyExpression)
        {
            if (Equals(currentValue, newValue))
            {
                return;
            }

            currentValue = newValue;
            this.RaisePropertyChanged(ExpressionHelper.Name(propertyExpression));
        }
    }
}
